#lang racket
(require "ircd.rkt")

(define port-no (make-parameter 6667))
(define bind-host (make-parameter #f))

(define cmdline-parsed
  (command-line
   #:program "move-night-chat"
   #:once-each
   [("-u" "--url")
    url
    "URL for the MoveNight chat server (default wss://stream.ihatebeinga.live/ws)"
    (movie-night-ws-url url)]
   [("-p" "--port")
    p
    "Specify the port for the IRCd (default 6667)"
    (let ([p (string->number p)])
      (if p
          (port-no p)
          (error "Cannot parse the port number")))]
   [("--host")
    h
    "Hostname to bind to (default #f == accept connections to all the addresses)"
    (bind-host h)]
   #:args ()
   (void)))

(define-values (main-thread kill-me)
  (serve #:port (port-no) #:hostname (bind-host)))

(printf
 "Started the ircd on port ~a :3 :3 :3
Run with --help to see all the options, nyaa.\n" (port-no))

(thread-wait main-thread)

